//
//  TipoGastoDAO.m
//  ViagemBem
//
//  Created by Rodrigo Morbach on 07/11/13.
//  Copyright (c) 2013 Michel de Sousa Carvalho. All rights reserved.
//

#import "TipoGastoDAO.h"
#import "AppDelegate.h"

@implementation TipoGastoDAO
+ (NSArray *)listarTiposGasto
{
    NSManagedObjectContext *context = [(AppDelegate *) [UIApplication sharedApplication].delegate managedObjectContext];
    NSFetchRequest *request = [[NSFetchRequest alloc] initWithEntityName:@"TipoGasto"];
    
    return  [context executeFetchRequest:request error:nil];
    
}

+(NSArray*) retornaTipoGasto:(NSString*)tpGasto{
    
    NSManagedObjectContext *context  = [TipoGastoDAO criarContexto];
    NSFetchRequest *request = [[NSFetchRequest alloc] initWithEntityName:@"TipoGasto"];
    request.predicate = [NSPredicate predicateWithFormat:@"tipo = %@",tpGasto];
    
    NSArray *a =  [context executeFetchRequest:request error:nil];
    return a;
}

+(NSManagedObjectContext*)criarContexto{
    NSManagedObjectContext *context = [(AppDelegate *) [UIApplication sharedApplication].delegate managedObjectContext];
    return context;
}
@end
